#include "ScnsPower.c.h"

#if defined(SCNS_POWER_ENABLE)&&SCNS_POWER_ENABLE==1

ScnsStatus scnsBspPowerInit(void)
{
    adc_init(ADC2_CH14_C4,ADC_10BIT);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspPowerPostInit(void)
{
    return SCNS_STATUS_OK;
}

float scnsBspPowerGetVoltage(void)
{
    uint16 origin=adc_convert(ADC2_CH14_C4);
    return 1.0f*origin/1024*3.3*3;
}

ScnsStatus scnsBspPowerIfNeedCharge(float u)
{
    return u<7.4?SCNS_STATUS_POWER_NEED_CHARGE:SCNS_STATUS_OK;
}

#endif